<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>5 元素居中</title>
  <style>
    .box {
      width: 200px;
      height: 200px;
      background: gold;
      /* 第一步，给父元素设置内填充 */
      padding: 50px 0 0 50px;
      /* 第二步 同时设置怪异盒模型，让padding值自动计算到整个盒子宽度，从而不影响整个盒子宽高 */
      box-sizing: border-box;
    }

    .son {
      width: 100px;
      height: 100px;
      background: orange;
    }
  </style>
</head>

<body>
  <div class="box">
    <div class="son"></div>
  </div>
</body>

</html>